package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"pod/podclient"
	"user/userclient"

	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config     config.Config
	Auth       rest.Middleware
	UserRpc    userclient.User
	PodcastRpc podclient.Podcast
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:     c,
		Auth:       middleware.NewAuthMiddleware().Handle,
		UserRpc:    userclient.NewUser(zrpc.MustNewClient(c.UserRpc)),
		PodcastRpc: podcastclient.NewPodcast(zrpc.MustNewClient(c.PodcastRpc)),
	}
}
